/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui.multimedia;

import java.util.ArrayList;
import javax.swing.JList;
import multimedia.AudioPlaylistModel;
import multimedia.AudioSongModel;

/**
 *
 * @author thomas
 */
public class MultimediaSongList extends JList {
    
    private MultimediaView _parent;
    private ArrayList<AudioSongModel> _songs;
    
    
    public MultimediaSongList(MultimediaView parent) {
        
        addMouseListener(parent);
        
        _parent = parent; 
        _songs = new ArrayList<AudioSongModel>();
        
    }
    
    public void setModel(AudioPlaylistModel apm) {
        setModel(new MultimediaSongListModel(apm.getSongs()));
    }
    
    public void update(AudioPlaylistModel apm) {
        
        MultimediaSongListModel model = new MultimediaSongListModel(apm.getSongs());
        setModel(model);
        
        for (AudioSongModel asm : model.getItemList()) {
            if (asm == apm.getCurrentSong()) {
                setSelectedValue(asm, true);
            }
        }
    }
}
